def solve(nums):
    res = []
    cnt = 0
    for i in range(len(nums)):
        if i > 0 and nums[i] == nums[i - 1]:
            continue
        else:
            res.append(nums[i])
            cnt += 1

    # nums[:cnt] = res  # 将res中的元素赋值给nums,不改变原数组长度
    nums[:]=res # 将res中的元素赋值给nums,改变原数组长度

    return len(res), nums


if __name__ == "__main__":
    nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]
    print(solve(nums))
